function wxPay(params) {
    return new Promise(resolve => {
        params.package = params.packageValue
        delete params.packageValue
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest',
            params,
            res => {
                resolve(res)
            })
    })

}

function initWxPay() {
    if (typeof WeixinJSBridge == "undefined") {
        if (document.addEventListener) {
            document.addEventListener('WeixinJSBridgeReady', wxPay, false);
        } else if (document.attachEvent) {
            document.attachEvent('WeixinJSBridgeReady', wxPay);
            document.attachEvent('onWeixinJSBridgeReady', wxPay);
        }
    }
}

export {
    wxPay,
    initWxPay
}